package com.yupi.yupicturebackend.model.enums;

import lombok.Getter;

@Getter // 这里只用getter的原因是枚举类的属性是final的，所以不需要setter方法
public enum SpaceLevelEnum {
    COMMON("普通版", 0, 100L, 100L * 1024 * 1024),

    PROFESSIONAL("专业版", 1, 1000L, 1000L * 1024 * 1024),

    FLAGSHIP("旗舰版", 2, 10000L, 10000L * 1024 * 1024);

    private final String text;

    private final int value;

    private final long maxCount;

    private final long maxSize;

    /**
     *
     * @param text 文本
     * @param value 值
     * @param maxCount 最大数量
     * @param maxSize 最大容量GB
     */
    SpaceLevelEnum(String text, int value, long maxCount, long maxSize) {
        this.text = text;
        this.value = value;
        this.maxCount = maxCount;
        this.maxSize = maxSize;
    }

    /**
     * 根据 value 获取枚举
     * @param value
     * @return
     */
    public static SpaceLevelEnum getEnumByValue(Integer value) {
        if (value == null) {
            return null;
        }
        for (SpaceLevelEnum anEnum : SpaceLevelEnum.values()) {
            if (anEnum.value == value) {
                return anEnum;
            }
        }
        return null;
    }
}
